/**
 * 显示提示消息
 * @param message 提示消息内容
 * @param duration 显示时长（毫秒）
 * @param isSuccess 是否为成功提示
 */
export function showToast(message: string, duration = 2000, isSuccess = true): void {
    // 移除已存在的提示
    const existingToast = document.querySelector('.kiki-toast');
    if (existingToast) {
        existingToast.remove();
    }

    // 创建新的提示元素
    const toast = document.createElement('div');
    toast.className = 'kiki-toast';
    toast.textContent = message;
    toast.style.cssText = `
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background-color: ${isSuccess ? 'rgba(0, 0, 0, 0.7)' : 'rgba(244, 67, 54, 0.9)'};
        color: white;
        padding: 10px 20px;
        border-radius: 4px;
        z-index: 10000;
        opacity: 0;
        transition: opacity 0.3s ease;
    `;
    document.body.appendChild(toast);

    // 触发重排以应用动画
    toast.offsetHeight;

    // 显示提示
    toast.style.opacity = '1';

    // 设置自动隐藏
    setTimeout(() => {
        toast.style.opacity = '0';
        setTimeout(() => {
            if (toast.parentNode) {
                toast.parentNode.removeChild(toast);
            }
        }, 300);
    }, duration);
} 